package com.cvnert.testplatform.controller;


import com.cvnert.testplatform.domain.Version;
import com.cvnert.testplatform.domain.vo.VersionVo;
import com.cvnert.testplatform.service.VersionService;
import com.cvnert.testplatform.utils.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/version")
public class VersionController {
    @Autowired
    private VersionService versionService;

    /**
     * 新增版本
     */
    @PostMapping("/addVersion")
    public ResultJson<Object> addVersion(@RequestBody Version version){
        return ResultJson.success(versionService.addVersion(version));
    }
    /**
     * 删除版本
     */
    @GetMapping("/deleteVersion/{vid}")
    public ResultJson<Object> deleteVersion(@PathVariable Integer vid){
        return ResultJson.success(versionService.deleteVersion(vid));
    }
    /**
     * 获取版本信息
     */
    @PostMapping("/getList")
    public ResultJson<Object> getList(@RequestBody VersionVo versionVo){
        return ResultJson.success(versionService.getList(versionVo));
    }
    /**
     * 修改版本信息
     */
    @PostMapping("/updateVersion")
    public ResultJson<Object> updateVersion(@RequestBody Version version){
        return ResultJson.success(versionService.updateVersion(version));
    }
    /**
     * 获取指定版本信息
     */
    @GetMapping("/getVersionDetail/{vid}")
    public ResultJson<Object> getVersionDetail(@PathVariable Integer vid){
        return ResultJson.success(versionService.getVersionDetail(vid));
    }
}
